package com.smu.recognize.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/*
*
* 静态资源拦截
* */
@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            registry.addResourceHandler("/xjy/photo/**")
                    // /app_file/**表示在磁盘filePathWindow目录下的所有资源会被解析为以下的路径
                    .addResourceLocations("file:" + "E:/IdeaProjects/recognize/");
        } else {  //linux 和mac
            log.info("图片拦截");
            registry.addResourceHandler("/xjy/photo/**")
                    .addResourceLocations("file:" + "/xjy/photo/") ;
        }
    }
}
